/*================================================================================
* CopyRight(c)2008, www.k-zone.cn. All rights reserved.
* Code licensed under the BSD License
* Author: Kenshin, Email: fxblog@gmail.com, Blog: http://www.k-zone.cn/zblog/
* Version：v0.1
* Data：2008-2-1
*===============================================================================*/
package com.ken.fanfou.as3
{
	import com.ken.fanfou.as3.friendships.Create;
	import com.ken.fanfou.as3.friendships.DestroyFriends;
	import com.ken.fanfou.as3.messages.DestroyMessage;
	import com.ken.fanfou.as3.messages.Inbox;
	import com.ken.fanfou.as3.messages.NewMessage;
	import com.ken.fanfou.as3.statuses.Destroy;
	import com.ken.fanfou.as3.statuses.FriendsTimeLine;
	import com.ken.fanfou.as3.statuses.PublicTimeLine;
	import com.ken.fanfou.as3.statuses.ShowTip;
	import com.ken.fanfou.as3.statuses.Update;
	import com.ken.fanfou.as3.statuses.UserTimeLine;
	import com.ken.fanfou.as3.user.Followers;
	import com.ken.fanfou.as3.user.Friends;
	import com.ken.fanfou.as3.user.Show;
	
	public class FanFouMethodFactory
	{
		/** 
		* 工厂设计模式的应用。
		* 
		* @param  传入了何种url、就在工厂模式下面装配何种方法。
		*         例如Type中的http://api.fanfou.com/users/show.xml等。
		* @param  是否进行HTTP Base验证，默认为验证。
		* @return 返回的是FanFouMethod
		* @langversion ActionScript 3.0
		* @playerversion Flash 9.0
		*/
		public static function createFanFouMethod(type:String,isValidate:Boolean = true):FanFouMethod{
			var api:FanFouMethod;
			switch(type){
				case Type.FANFOU_USER_TIMELINE:         //api.fanfou.com/statuses/user_timeline.rss
					api = new UserTimeLine(type,isValidate);
					break;
				case Type.FANFOU_FRIENDS_TIMELINE:      //api.fanfou.com/statuses/friends_timeline.rss
				    api = new FriendsTimeLine(type,isValidate);
				    break;
				case Type.FANFOU_PUBLIC_TIMELINE:       //api.fanfou.com/statuses/public_timeline.rss
					api = new PublicTimeLine(type,isValidate);
					break;
				case Type.FANFOU_SHOWTIP:               //api.fanfou.com/statuses/show.xml
					api = new ShowTip(type);
					break;
				case Type.FANFOU_UPDATE:                //api.fanfou.com/statuses/update.xml
					api = new Update(type);
					break;
				case Type.FANFOU_DESTROY:               //api.fanfou.com/statuses/destroy.xml
					api = new Destroy(type);
					break;
				case Type.FANFOU_FRIENDS:               //api.fanfou.com/users/friends.xml
					api = new Friends(type,isValidate);
					break;
				case Type.FANFOU_FOLLOWER:              //api.fanfou.com/users/followers.xml
					api = new Followers(type,isValidate);
					break;
				case Type.FANFOU_SHOW:                  //api.fanfou.com/users/show.xml
					api = new Show(type,isValidate);
					break;
				case Type.FANFOU_CREATE_FRIENDS:        //api.fanfou.com/friendships/create.xml
					api = new Create(type);
					break;
				case Type.FANFOU_DESTROY_FRIENDS:       //api.fanfou.com/friendships/destroy.xml
					api = new DestroyFriends(type);
					break;
				case Type.FANFOU_PRIVATE_MESSAGE_INBOX:  //api.fanfou.com/private_messages/inbox.xml
					api = new Inbox(type);
					break;
				case Type.FANFOU_PRIVATE_MESSAGE_NEW:    //api.fanfou.com/private_messages/new.xml
					api = new NewMessage(type);
					break;
				case Type.FANFOU_PRIVATE_MESSAGE_DESTORY: //api.fanfou.com/private_messages/destroy.xml
					api = new DestroyMessage(type);
					break;
			}
			return api;
		}
	}
}
